Direct likelihood of fully observed models ========================================== When every variable of a model is observed and the data are complete, the shocks of every period follow from the data, provided the map from the shocks to the observed variables can be inverted. The likelihood is then the density of those shocks times the Jacobian term of the map, with the Hamilton recursion over the regimes. ``estimate`` takes this route by itself for the maps whose density is **proved** to have such a closed form, and filters every other model. For a reduced-form VAR the route also gives the exact score of the posterior, on the conditions of :doc:`Exact score of switching VARs`. .. contents:: :local: :depth: 1 The two classes --------------- The proof (``rise.engine.dsge_tools.estim.direct_route_class``) reads the model's structural metadata, not the values of its solution. The metadata are the coordinates of the symbolic derivatives of the equations that are not identically zero, and the time incidence of the variables. The perturbation parameter sig and the observed exogenous variables are known inputs. **Class A: affine.** The solution is affine in the shocks of the period, with an impact that depends neither on the state nor on the shocks. * **When.** For every first-order solution, and above the first order for a model whose equations have no second derivative between two endogenous variables or shocks, nor between one of them and an observed exogenous variable. ``(1+d)*x = e``, with an observed ``d``, is not class A: its order-2 policy is ``x = e - d*e``, whose impact varies with the data. * **Density.** The data have the Gaussian density :math:`N(A_0(t), A_1A_1')` on the rows the shocks move. No injectivity is needed, so maps with more shocks than observed variables they move are included. * **Computation.** It is the computation of the direct route before this release: * one Cholesky factor per regime; * the rows the shocks move are those with a coefficient above 1e-12, a compatibility convention; * the reported shocks are the conditional mean :math:`E[\varepsilon_t \mid r_t]`. **Class B: triangular, affine in each pivot.** Every shock enters one equation, affinely, and that equation determines one observed variable, its pivot. The pivots can be ordered so that each depends, in the period, only on earlier pivots and on predetermined variables. In full: * **B1.** The shock appears in its equation only, and that equation holds no other shock. * **B2.** The equation is affine in its pivot and its shock: no second derivative pairs either of them with an endogenous variable, a shock or an observed exogenous variable. * **B3.** The other variables of the equation in the period are earlier pivots or predetermined variables. When the equation has leads, its pivot is not a state variable, since its expectation would depend on it. * **B4.** The other equations hold, in the period, only predetermined variables: no pivot, no shock, no lead. * **B5.** No transition driver is a pivot. Then, at every perturbation order, pruned or not, each pivot is .. math:: v_i = G_i(\text{state}, \varepsilon_{